<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>ilib_for_link</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 29/06/2005</div>
    <p>
      <b>ilib_for_link</b> -  utility for shared library management with link</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>libn=ilib_for_link(names,files,libs,flag [,makename
      [,loadername [,libname [,ldflags [,cflags [,fflags [,cc]]]]]]])  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>names</b>
        </tt>: a string matrix giving the entry names which are to be linked.</li>
      <li>
        <tt>
          <b>files</b>
        </tt>: string matrix giving objects files needed for shared library creation</li>
      <li>
        <tt>
          <b>libs</b>
        </tt>: string matrix giving extra libraries needed for shred library creation</li>
      <li>
        <tt>
          <b>flag</b>
        </tt>: a string flag ("c" or "f") for C or Fortran entry points.</li>
      <li>
        <tt>
          <b>makename</b>
        </tt>: character string. The pathname of the Makefile file without extension (default value <tt>
          <b>Makelib</b>
        </tt>).</li>
      <li>
        <tt>
          <b>loadername</b>
        </tt>: character string. The pathname of the loader file (default
	    value is   <tt>
          <b>loader.sce</b>
        </tt>).</li>
      <li>
        <tt>
          <b>libname</b>
        </tt>: optional character string. The name of the generated shared
	    library (default value  is '', and in this case the name is derived
	    from <tt>
          <b>names(1)</b>
        </tt>).</li>
      <li>
        <tt>
          <b>ldflags</b>
        </tt>: optional character string. It can be used to add specific linker options in the
	    generated Makefile. Default value is ''</li>
      <li>
        <tt>
          <b>cflags</b>
        </tt>: optional character  string. It can be used to add specific C compiler options in the
	    generated Makefile. Default value is ''</li>
      <li>
        <tt>
          <b>fflags</b>
        </tt>: optional character  string. It can be used to add specific Fortran compiler options in the
	    generated Makefile. Default value is ''</li>
      <li>
        <tt>
          <b>cc</b>
        </tt>: optional character  string. It can be used to specify a C compiler. Default value is ''</li>
      <li>
        <tt>
          <b>libn</b>
        </tt>: character string. The path of the really generated shared library file.</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    This tool is used to create shared libraries and to generate a 
    loader file which can be used to dynamically load the shared library 
    into Scilab with the <tt>
        <b>link</b>
      </tt> function. New entry points 
    given by <tt>
        <b>names</b>
      </tt> are then accessible through the <tt>
        <b>call</b>
      </tt> 
    function or with non linear tools <tt>
        <b>ode</b>
      </tt>, <tt>
        <b>optim</b>
      </tt>,...</p>
    <p>
    The file to compile are supposed to be located given by
    <tt>
        <b>makename</b>
      </tt>. If <tt>
        <b>makename</b>
      </tt> sets a path different to the
    current directory, <tt>
        <b>loader</b>
      </tt> script must be located in
    the same directory using the <tt>
        <b>loadername</b>
      </tt> variable.</p>
    <p>
    Many examples are provided in <tt>
        <b>examples/link-examples-so</b>
      </tt>
    directory.</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>


f1=['int ext1c(n, a, b, c)'
    'int *n;     double *a, *b, *c;'
    '{int k;'
    '  for (k = 0; k &lt; *n; ++k) '
    '      c[k] = a[k] + b[k];'
    '  return(0);}'];

mputl(f1,'fun1.c')

//creating the shared library (a gateway, a Makefile and a loader are 
//generated. 

ilib_for_link('ext1c','fun1.o',[],"c") 

// load the shared library 

exec loader.sce 

//using the new primitive
a=[1,2,3];b=[4,5,6];n=3;
c=call('ext1c',n,1,'i',a,2,'d',b,3,'d','out',[1,3],4,'d');
if norm(c-(a+b)) &gt; %eps then pause,end

 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="../functions/addinter.htm">
        <tt>
          <b>addinter</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="link.htm">
        <tt>
          <b>link</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_compile.htm">
        <tt>
          <b>ilib_compile</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_gen_Make.htm">
        <tt>
          <b>ilib_gen_Make</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_gen_gateway.htm">
        <tt>
          <b>ilib_gen_gateway</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_gen_loader.htm">
        <tt>
          <b>ilib_gen_loader</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="ilib_for_link.htm">
        <tt>
          <b>ilib_for_link</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
